const express = require('express');
// 引入路由
const joi = require('joi');
const router = require('./router/user');

const app = express();


app.use((err, req, res, next) => {
    if (err.name === 'UnauthorizedError') {
        return res.cc('身份认证失败')
    } else if (err instanceof joi.ValidationError) {
        return res.cc(err)
    }
    res.cc(err)
    next()
})
// 使用路由
app.use(router);
// 挂载静态资源
app.use(express.static('web'));
app.listen(8080, () => {
    console.log('http://localhost:8080')
});